{% extends 'front/user_base.html' %}
{% block css %}
    <link rel="stylesheet"
          href="{{ url_for('static', filename='css/pure-min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('static', filename='css/create.css') }}">
{% endblock %}
{% block content %}

<div class="content">
    <div class="header">
        <h2>编辑俱乐部</h2>
    </div>
    <div class="pure-g">
        {% for category, message in get_flashed_messages(with_categories=true) %}
            <div class="alert alert-{{ category }} alert-dismissable pure-u-1 pure-u-md-21-24">
                {{ message }}
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            </div>
        {% endfor %}
        <form class="pure-form pure-form-aligned pure-u-1 pure-u-md-21-24" action="{{ url_for('main.update_club') }}" method="post" onsubmit="return checkPost()">
            <fieldset>
                {{ form.csrf_token }}
                {{ form.club_id(class='pure-u-2-3', id="club_id") }}
                <div class="pure-control-group ">
                    <label for="name" class="pure-u-1-3">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称</label>
                    {{ form.name(class='pure-u-2-3', id="name",placeholder="输入名称", required='') }}
                </div>
                <div class="pure-control-group">
                    <label for="password" class="pure-u-1-3">访问密码</label>
                    {{ form.password(class='pure-u-2-3', id="password",placeholder="如果要修改，请填写新的访问密码") }}
                </div>
                <div class="pure-control-group">
                    <label for="desc" class="pure-u-1-3">简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;介</label>
                    {{ form.desc(class='pure-u-2-3', id="desc",placeholder="输入简介", required='') }}
                </div>
                <div class="pure-controls" style="text-align: right">
                    <button type="submit" class="button-success pure-button button-large pure-u-3-3" style="margin-right: 100px">
                        保存
                    </button>
                </div>
            </fieldset>
        </form>
    </div>
</div>
{% endblock %}
{% block scripts %}
    <script src="{{ url_for('static', filename='layer-v3.5.1/layer.js') }}"></script>
<script>
    function checkPost(){
        let name = jQuery("#name").val()
        let password = jQuery("#password").val()
        let desc = jQuery("#desc").val()
        if(name.length < 3){
            layer.msg("名称不能小于3个字符")
            return false
        }
        if(password.length >0){
            if(password.length < 6 || password.length> 16){
                layer.msg("密码长度应该在6和16之间")
                return false
            }
        }
        if(desc.length < 6 || password.length> 32){
            layer.msg("简介长度应该在6和16之间")
            return false
        }
        return true
    }
    </script>
{% endblock %}